package com.trip.wechat.platform.service.impl;

import com.trip.wechat.platform.dao.WechatSubscribeUserDao;
import com.trip.wechat.platform.domain.WechatSubscribeUserPO;
import com.trip.wechat.platform.param.WechatSubscribeUserParam;
import com.trip.wechat.platform.service.WechatSubscribeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WechatSubscribeUserServiceImpl implements WechatSubscribeUserService {

    @Autowired
    private WechatSubscribeUserDao wechatSubscribeUserDao;

    public boolean updateWechatSubscribeUser(WechatSubscribeUserPO wechatSubscribeUserPO){
        return wechatSubscribeUserDao.updateWechatSubscribeUser(wechatSubscribeUserPO);
    }

    @Override
    public Integer getUserSubscribeStatus(String openId, String publicKey, String sceneId) {
        WechatSubscribeUserParam param = new WechatSubscribeUserParam();
        param.setOpenId(openId);
        param.setPublicKey(publicKey);
        param.setSceneId(sceneId);
        Integer userSubscribeStatus = wechatSubscribeUserDao.getUserSubscribeStatus(param);
        return userSubscribeStatus==null?1:userSubscribeStatus;
    }

}
